<template>
	<view class="store">
		<view class="head" :style="{height: pHeight + tHeight + 'px'}">
			<view class="xztitle" :style="[{height: pHeight + 'px', top: tHeight + 'px',lineHeight: pHeight + 'px'}]">
				门店管理
				<view class="iconfont icon-dayuhao1" @click="fanhui"></view>
			</view>
		</view>
		<view class="headtop" :style="{marginTop: pHeight + tHeight + 'px'}">
			<view class="top clearfix">
				<view class="left fl clearfix">
					<view class="mess fl">
						<view :class="[attrIndex==1?'active':'']" @click="zhiying(1)">直营门店</view>
						<text class="dian" v-if="attrIndex == 1"></text>
					</view>
					<view class="mess mess1 fl" @click="zhiying(2)" v-if="attrIf">
						<view :class="[attrIndex==2?'active':'']">团队门店</view>
						<text class="dian" v-if="attrIndex == 2"></text>
					</view>
				</view>
				<view class="right fr clearfix" @click="shaixuan">
					<image :src="baseUrl + '/wximage/shaixuan.png'" class="fl"></image>
					<view class="name fl">筛选</view>
					<!-- <u-select v-model="showstatus" :list="timelist" @confirm="confirm"></u-select> -->
				</view>
				<!-- <view class="right fr clearfix" @click="showstatus = true">
					<image :src="baseUrl + '/wximage/shaixuan.png'" class="fl"></image>
					<view class="name fl">筛选</view>
					<u-select v-model="showstatus" :list="timelist" @confirm="confirm"></u-select>
				</view> -->
			</view>
			<view class="sousuo clearfix">
				<input type="text" placeholder="请输入关键字" v-model="formData.search" @confirm="searchc()" />
				<image :src="baseUrl + '/wximage/sousuo.png'" @click="searchc()"></image>
			</view>
			<view class="bottom clearfix">
				<!-- <view class="left fl clearfix" @click="shaixuan">
					<image :src="baseUrl + '/wximage/shaixuan.png'" class="fl"></image>
					<view class="name fl">筛选</view>
				</view> -->
				<!-- <view class="right fr clearfix" v-if="hidden == true" @click="hidden = false">
					<image :src="baseUrl + '/wximage/yincang.png'" class="fl"></image>
					<view class="name fl">显示合作结束门店</view>
				</view>
				<view class="right fr clearfix" v-else @click="hidden = true">
					<image :src="baseUrl + '/wximage/xianshi.png'" class="fl"></image>
					<view class="name fl">隐藏合作结束门店</view>
				</view> -->
			</view>
		</view>
		<view class="morebeijing" v-if="morebjstatus" @click="guanbi"></view>
		<view class="moretankuang" v-if="morestatus">
			<view class="bankuai">
				<view class="top">创建时间<text class="chongzhi" @click="datereset">重置</text></view>
				<view class="time">
					<text>{{formData.sdate}}</text>至<text>{{formData.edate}}</text>
				</view>
				<view class="bottom clearfix">
					<text @click="show = true">开始时间</text>
					<text @click="show = true">结束时间</text>
				</view>
				<u-calendar v-model="show" :mode="mode" toolTip="时间选择" @change="change"></u-calendar>
			</view>
			<!-- <view class="bankuai">
				<view class="top">设备数量<text class="chongzhi" @click="devicereset">重置</text></view>
				<view class="shurubottom">
					<view class="tishi">请输入设备数量</view>
					<view class="shuru clearfix">
						<input type="text" v-model="formData.sdevnum" placeholder="0" class="fl" value="0" />
						<text class="fl">至</text>
						<input type="text" v-model="formData.edevnum" placeholder="99999" value="99999" class="fl" />
					</view>
				</view>
			</view> -->
			<view class="queren" @click="queren">
				确认
			</view>
		</view>
		<view class="shuju" v-if="stationList.length != 0">
			<view class="li" @click="topage('/subpackageA/store/detail?stationid='+item.id)" v-for="(item,index) in stationList" :key="index">
				<view class="top clearfix">
					<image :src="item.sitepicture" class="fl"></image>
					<view class="cen fl">
						<text class="title">{{item.name}}</text>
						<text class="shebei">设备台数：{{item.stationsum}}</text>
						<text class="time" v-if="item.charger_agents_name==null||item.charger_agents_name==''">所属代理商：平台</text>
						
						<text class="time" v-else>所属代理商：{{item.charger_agents_name}}</text>
						
						<text class="time">所属商户：{{item.charger_bussiness_name}}</text>
					</view>
				</view>
				<view class="address addressts clearfix">
					<image :src="baseUrl + '/wximage/dizhi.png'" class="fl"></image>
					<text class="fl">地址：{{item.full_address}}</text>
				</view>
			</view>
		</view>
		<view class="empty" v-else>
			<image :src="baseUrl + '/wximage/empty.png'"></image>
			<text>暂无相关数据</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseUrl: getApp().globalData.baseUrl,
				headerTop: 0,
				pHeight: 0,
				tHeight: 0,
				attrIndex: 1,
				showstatus: false,
				timelist: [{
					value: '0',
					label: '全部',
				}, {
					value: '1',
					label: '待合作',
				}, {
					value: '2',
					label: '合作中',
				}, {
					value: '3',
					label: '合作结束',
				}],
				value: '',
				list: [1],
				hidden: true,
				morebjstatus: false,
				morestatus: false,
				show: false,
				mode: 'range',
				sdate: '--',
				edate: '--',
				formData: {
					id:uni.getStorageSync('agent_id'),
					page:1,
					pageSize:20,
					search:'',
					sdate:'',
					edate:'',
					sdevnum:'',
					edevnum:''
				},
				stationList: [],
				attrIf:false,
			}
		},
		onLoad() {
			// 头部距离
			let res = uni.getSystemInfoSync() ///微信api方法
			let titleH;
			if (res && res['system']) {
				// 判断是否是安卓操作系统 （标题栏苹果为44px,安卓为48px）
				if (res['system'].indexOf('Android') > 0) {
					titleH = 48
				} else {
					titleH = 46
				}
				this.headerTop = titleH + res['statusBarHeight']
				this.pHeight = titleH
				this.tHeight = res['statusBarHeight']
			}
			if(uni.getStorageSync('role_id') ==13){
				this.attrIf = false;
			}else{
				this.attrIf = true;
			}
			this.getStation();
		},
		methods: {
			devicereset(){
				this.formData.sdevnum = '';
				this.formData.edevnum = '';
			},
			datereset(){
				this.formData.sdate = '';
				this.formData.edate = '';
			},
			searchc(){
				this.stationList = [];
				this.getStation();
			},
			zhiying(e){
				this.attrIndex = e;
				this.stationList = [];
				this.formData.page=1;
				this.formData.pageSize=20;
				this.formData.search='';
				this.getStation();
			},
			getStation(){
				if(this.attrIndex==1){
					//获取登陆人id
					var id = uni.getStorageSync('agent_id');
					this.request({
						url: '/agent/allstationlist',
						data: this.formData,
						method: "GET"
					}).then(res => {
						if (res.data.code == 200) {
							if(res.data.data.stationlist!=null){
								this.stationList = res.data.data.stationlist;
							}
						} else {
							uni.showToast({
								title: res.data.message,
								icon: 'none'
							})
						}
					})
				}else{
					//获取登陆人id
					var id = uni.getStorageSync('agent_id');
					this.request({
						url: '/agent/allstationlist1',
						data: this.formData,
						method: "GET"
					}).then(res => {
						if (res.data.code == 200) {
							if(res.data.data.stationlist!=null){
								this.stationList = res.data.data.stationlist;
							}
						} else {
							uni.showToast({
								title: res.data.message,
								icon: 'none'
							})
						}
					})
				}
			},
			// 点击确认
			queren(){
				this.morebjstatus = !this.morebjstatus;
				this.morestatus = !this.morestatus;
				
				this.formData.page = 1;
				this.formData.search = '';
				this.stationList = [];
				this.getStation();
				
			},
			confirm(e) {
				this.value = e[0].value;
				console.log(this.value)
			},
			shaixuan(){
				this.morebjstatus = !this.morebjstatus;
				this.morestatus = !this.morestatus;
			},
			guanbi(){
				this.morebjstatus = !this.morebjstatus;
				this.morestatus = !this.morestatus;
			},
			change(e) {
				this.formData.sdate = e.startDate;
				this.formData.edate = e.endDate;
			},
			fanhui() {
				uni.navigateBack();
			},
			topage(url) {
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #f9f9ff;
	}
	
	.store {
		width: 100%;
		margin: 0 auto;

		.head {
			width: 100%;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 99;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);

			.xztitle {
				position: fixed;
				left: 0%;
				top: 0;
				width: 100%;
				text-align: left;
				color: #333333;
				font-size: 32rpx;
				padding-left: 74rpx;
				font-weight: 700;

				text {
					font-size: 24rpx;
				}

				.iconfont {
					position: absolute;
					top: 0;
					left: 30rpx;
					font-size: 44rpx;
				}
			}
		}

		.headtop {
			width: 100%;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);
			height: 300rpx;
			padding: 20rpx 40rpx 0;
			box-sizing: border-box;

			.top{
				.left {
					.mess {
						height: 48rpx;
						line-height: 48rpx;
						text-align: center;
				
						view {
							font-size: 24rpx;
							color: #333333;
						}
				
						.dian {
							width: 8rpx;
							height: 8rpx;
							background: #5C88FA;
							display: block;
							border-radius: 50%;
							margin: 0 auto;
						}
				
						.active {
							font-size: 32rpx;
							color: #333333;
							font-weight: 700;
							margin-left: 0;
						}
					}
				
					.mess1 {
						margin-left: 20rpx;
					}
				}
				
				.right {
					width: 116rpx;
					height: 36rpx;
					line-height: 36rpx;
					text-align: center;
					background: #FFFFFF;
					border-radius: 24rpx;
					margin-top: 6rpx;
				
					image {
						width: 36rpx;
						height: 36rpx;
						margin-left: 10rpx;
						margin-right: 6rpx;
					}
				
					.name {
						font-size: 24rpx;
						color: #333333;
					}
				}
			}

			.sousuo {
				width: 100%;
				box-sizing: border-box;
				position: relative;
				margin-top: 30rpx;

				input {
					width: 100%;
					height: 60rpx;
					line-height: 60rpx;
					background: #ffffff;
					border-radius: 30rpx;
					padding-left: 30rpx;
					color: #999999;
					box-sizing: border-box;
				}

				image {
					width: 72rpx;
					height: 40rpx;
					position: absolute;
					right: 10rpx;
					top: 10rpx;
					z-index: 10;
				}
			}
			
			.bottom{
				margin-top: 14rpx;
				
				.left {
					width: 116rpx;
					height: 36rpx;
					line-height: 36rpx;
					text-align: center;
					background: #E6E9FF;
					border-radius: 24rpx;
					margin-top: 6rpx;
				
					image {
						width: 36rpx;
						height: 36rpx;
						margin-left: 10rpx;
						margin-right: 6rpx;
					}
				
					.name {
						font-size: 24rpx;
						color: #333333;
					}
				}
				
				.right {
					width: 262rpx;
					height: 36rpx;
					line-height: 36rpx;
					text-align: center;
					background: #FFFFFF;
					border-radius: 24rpx;
					margin-top: 6rpx;
				
					image {
						width: 36rpx;
						height: 36rpx;
						margin-left: 10rpx;
						margin-right: 6rpx;
					}
				
					.name {
						font-size: 24rpx;
						color: #333333;
					}
				}
			}
		}
		
		.shuju{
			width: 100%;
			padding: 30rpx 20rpx;
			box-sizing: border-box;
			margin-top: -140rpx;
			
			.li{
				width: 100%;
				position: relative;
				background: #fff;
				border-radius: 20rpx;
				margin-bottom: 20rpx;
				padding: 30rpx 28rpx;
				box-shadow: rgba(223, 230, 255, 0.67) 0px 0px 6px;
				
				image{
					width: 150rpx;
					height: 150rpx;
				}
				
				.cen{
					width: 390rpx;
					margin-left: 20rpx;
					
					text{
						display: block;
					}
					
					.title{
						font-size: 28rpx;
						color: #333333;
						font-weight: 700;
						margin-bottom: 8rpx;
					}
					
					.shebei{
						font-size: 22rpx;
						color: #3B91F8;
					}
					
					.time{
						font-size: 24rpx;
						color: #999999;
						line-height: 36rpx;
					}
				}
				
				.you{
					position: absolute;
					top: 30rpx;
					right: 30rpx;
					font-size: 28rpx;
					font-weight: 700;
				}
				
				.zhuangtai{
					color: #FA5E5C;
				}
				
				.zhuangtai1{
					color: #3B91F8;
				}
				
				.zhuangtai2{
					color: #999999;
				}
				
				.address{
					margin-top: 10rpx;
					
					image{
						width: 30rpx;
						height: 30rpx;
						margin-top: 4rpx;
					}
					
					text{
						display: inline-block;
						line-height: 32rpx;
						font-size: 24rpx;
						color: #666666;
						width: 90%;
					}
				}
				
				.addressts{
					
					text{
						// width: 62%;
					}
				}
				
				.bili{
					position: absolute;
					right: 28rpx;
					bottom: 30rpx;
					width: 180rpx;
					height: 60rpx;
					line-height: 60rpx;
					text-align: center;
					background: #3B91F8;
					color: #FFFFFF;
					border-radius: 16rpx;
					font-size: 28rpx;
				}
			}
		}

		.empty {
			width: 100%;
			margin: 200rpx auto 0;
			text-align: center;

			image {
				width: 390rpx;
				height: 340rpx;
			}

			text {
				display: block;
				margin-top: 60rpx;
				font-size: 24rpx;
				color: #666666;
			}
		}
		
		.morebeijing{
			position: absolute;
			bottom: 0;
			left: 0;
			width: 100%;
			height: 100vh;
			background: #000000;
			opacity: 0.5;
			z-index: 100;
		}
		
		.moretankuang{
			position: absolute;
			bottom: 0;
			left: 0;
			width: 100%;
			height: 450rpx;
			background: #fff;
			z-index: 200;
			border-top-left-radius: 20rpx;
			border-top-right-radius: 20rpx;
			padding: 20rpx 0;
			
			.bankuai{
				
				.top{
					background: #FDFDFD;
					font-size: 32rpx;
					color: #333333;
					height: 72rpx;
					line-height: 72rpx;
					padding-left: 40rpx;
					box-sizing: border-box;
					border-bottom: 1rpx solid #DFE6FF;
					position: relative;
					
					.chongzhi{
						position: absolute;
						top: 8rpx;
						right: 40rpx;
						width: 136rpx;
						height: 48rpx;
						line-height: 48rpx;
						text-align: center;
						border-radius: 16rpx;
						color: #333333;
						background: #E3F2FF;
						font-size: 24rpx;
					}
					
				}
				
				.time{
					margin-top: 20rpx;
					margin-left: 40rpx;
					font-size: 24rpx;
					color: #333333;
					
					text:nth-of-type(1){
						font-size: 24rpx;
						color: #FA5E5C;
					}
					
					text:nth-of-type(2){
						font-size: 24rpx;
						color: #5C88FA;
					}
				}
				
				.bottom{
					margin-top: 40rpx;
					margin-bottom: 50rpx;
					
					text{
						display: inline-block;
						margin-left: 60rpx;
						width: 160rpx;
						height: 54rpx;
						text-align: center;
						border-radius: 16rpx;
						line-height: 54rpx;
						background: #F6F6F6;
						font-size: 24rpx;
						color: #333333;
					}
					
					.active{
						background: #E3F2FF;
					}
				}
				
				.shurubottom{
					margin-top: 20rpx;
					margin-bottom: 50rpx;
					width: 100%;
					padding: 0 40rpx;
					
					.tishi{
						font-size: 24rpx;
						color: #333333;
					}
					
					.shuru{
						width: 60%;
						margin: 0 auto;
						text-align: center;
						height: 50rpx;
						line-height: 50rpx;
						margin-top: 40rpx;
						
						input{
							width: 33.3%;
							text-align: center;
							height: 50rpx;
							line-height: 50rpx;
							color: #3B91F8;
							border-bottom: 1rpx solid #E3F2FF;
						}
						
						text{
							display: inline-block;
							width: 33.3%;
						}
					}
				}
			}
			
			.queren{
				width: 180rpx;
				margin: 0 auto;
				height: 60rpx;
				line-height: 60rpx;
				border-radius: 16rpx;
				text-align: center;
				background: #3B91F8;
				margin-top: 100rpx;
				font-size: 28rpx;
				color: #FFFFFF;
			}
		}
	}
</style>